﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace Player.ShangCheng
{
    public partial class SCjx : System.Web.UI.Page
    {
        //窗体加载事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                #region //显示对应游戏类型-大类
                if (Request.QueryString["typeid"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["typeid"]);
                    switch (id)
                    {
                        case 1:
                            this.lbl_typetxt.Text = "精选游戏";
                            this.dtlsjx.DataSource = BLL.GameManage.SeleJingXuanGame();
                            this.dtlsjx.DataBind();
                            break;
                        case 2:
                            this.lbl_typetxt.Text = "免费游戏";
                            this.dtlsjx.DataSource = BLL.GameManage.SeleMianFeiGame();
                            this.dtlsjx.DataBind();
                            break;
                        case 3:
                            this.lbl_typetxt.Text = "付费游戏";
                            this.dtlsjx.DataSource = BLL.GameManage.SeleFuFeiGame();
                            this.dtlsjx.DataBind();
                            break;
                    }
                    return;
                }
                #endregion

                #region //显示对应游戏类型-小类
                if (Request.QueryString["id"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    //显示对应类型游戏
                    this.dtlsjx.DataSource = BLL.GameManage.SeleTypeIdGame(id);
                    this.dtlsjx.DataBind();
                    //获取游戏类型
                    List<GmType> ls = BLL.GmTypeManage.SeleIdGmType(id);
                    this.lbl_typetxt.Text = ls[0].Gt_Name.ToString();
                    return;
                }
                #endregion

                #region //显示所有游戏
                this.dtlsjx.DataSource = BLL.GameManage.SeleAllGame();
                this.dtlsjx.DataBind();
                #endregion
            }
        }

        //搜索按钮
        protected void btn_sousuo_Click(object sender, EventArgs e)
        {
            //获取搜索内容
            string txt = this.txt_txt.Text.Trim();
            if (txt==string.Empty)
            {
                return;
            }
            //显示查询内容
            this.dtlsjx.DataSource = BLL.GameManage.SeleNameLikeGame(txt);
            this.dtlsjx.DataBind();
        }

        //按人气升序
        protected void imgbtn_RQsheng_Click(object sender, ImageClickEventArgs e)
        {
            #region //游戏大分类排序
            if (Request.QueryString["typeid"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["typeid"]);
                switch (id)
                {
                    case 1:
                        this.lbl_typetxt.Text = "精选游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleJXRQShengGame();
                        this.dtlsjx.DataBind();
                        break;
                    case 2:
                        this.lbl_typetxt.Text = "免费游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleMFRQShengGame();
                        this.dtlsjx.DataBind();
                        break;
                    case 3:
                        this.lbl_typetxt.Text = "付费游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleFFRQShengGame();
                        this.dtlsjx.DataBind();
                        break;
                }
                return;
            }
            #endregion

            #region //游戏类型排序-小类
            if (Request.QueryString["id"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                this.dtlsjx.DataSource = BLL.GameOrderManage.SeleMinRQShengGame(id);
                this.dtlsjx.DataBind();

                //显示游戏类型
                List<GmType> ls = BLL.GmTypeManage.SeleIdGmType(id);
                this.lbl_typetxt.Text = ls[0].Gt_Name.ToString();
                return;
            }
            #endregion

            #region //全部游戏排序
            this.dtlsjx.DataSource = BLL.GameManage.SeleRQShengXuGame();
            this.dtlsjx.DataBind();
            #endregion

        }

        //按人气降序
        protected void imgbtn_RQjiang_Click(object sender, ImageClickEventArgs e)
        {
            #region //游戏大分类排序
            if (Request.QueryString["typeid"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["typeid"]);
                switch (id)
                {
                    case 1:
                        this.lbl_typetxt.Text = "精选游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleJXRQJiangGame();
                        this.dtlsjx.DataBind();
                        break;
                    case 2:
                        this.lbl_typetxt.Text = "免费游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleMFRQJiangGame();
                        this.dtlsjx.DataBind();
                        break;
                    case 3:
                        this.lbl_typetxt.Text = "付费游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleFFRQJiangGame();
                        this.dtlsjx.DataBind();
                        break;
                }
                return;
            }
            #endregion

            #region //游戏类型排序-小类
            if (Request.QueryString["id"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                this.dtlsjx.DataSource = BLL.GameOrderManage.SeleMinRQJiangGame(id);
                this.dtlsjx.DataBind();

                //获取游戏类型
                List<GmType> ls = BLL.GmTypeManage.SeleIdGmType(id);
                this.lbl_typetxt.Text = ls[0].Gt_Name.ToString();
                return;
            }
            #endregion

            #region 全部游戏排序
            this.dtlsjx.DataSource = BLL.GameManage.SeleRQJiangXuGame();
            this.dtlsjx.DataBind();
            #endregion
            
        }

        //按价格升序
        protected void imgbtn_JGsheng_Click(object sender, ImageClickEventArgs e)
        {
            #region //游戏大分类排序
            if (Request.QueryString["typeid"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["typeid"]);
                switch (id)
                {
                    case 1:
                        this.lbl_typetxt.Text = "精选游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleJXJGShengGame();
                        this.dtlsjx.DataBind();
                        break;
                    case 3:
                        this.lbl_typetxt.Text = "付费游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleFFJGShengGame();
                        this.dtlsjx.DataBind();
                        break;
                }
                return;
            }
            #endregion

            #region //游戏类型排序
            if (Request.QueryString["id"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                this.dtlsjx.DataSource = BLL.GameOrderManage.SeleMinJGShengGame(id);
                this.dtlsjx.DataBind();

                //获取游戏类型
                List<GmType> ls = BLL.GmTypeManage.SeleIdGmType(id);
                this.lbl_typetxt.Text = ls[0].Gt_Name.ToString();
                return;
            }
            #endregion

            #region //全部游戏排序
            this.dtlsjx.DataSource = BLL.GameManage.SeleJGShengGame();
            this.dtlsjx.DataBind();
            #endregion

        }

        //按价格降序
        protected void imgbtn_JGjiang_Click(object sender, ImageClickEventArgs e)
        {
            #region //游戏大分类排序
            if (Request.QueryString["typeid"]!=null)
            {
                int id = Convert.ToInt32(Request.QueryString["typeid"]);
                switch (id)
                {
                    case 1:
                        this.lbl_typetxt.Text = "精选游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleJXJGJiangGame();
                        this.dtlsjx.DataBind();
                        break;
                    case 3:
                        this.lbl_typetxt.Text = "付费游戏";
                        this.dtlsjx.DataSource = BLL.GameOrderManage.SeleFFJGJiangGame();
                        this.dtlsjx.DataBind();
                        break;
                }
                return;
            }
            #endregion

            #region //游戏类型排序
            if (Request.QueryString["id"] != null)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                this.dtlsjx.DataSource = BLL.GameOrderManage.SeleMinJGJiangGame(id);
                this.dtlsjx.DataBind();

                //获取游戏类型
                List<GmType> ls = BLL.GmTypeManage.SeleIdGmType(id);
                this.lbl_typetxt.Text = ls[0].Gt_Name.ToString();
                return;
            }
            #endregion

            #region //全部游戏排序
            this.dtlsjx.DataSource = BLL.GameManage.SeleJGJiangGame();
            this.dtlsjx.DataBind();
            #endregion
            
        }

    }
}